home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / os2 / adaptor.zip / ADAPT.ZIP / adaptor / src / buildtre.c < prev    next >
Text File  |  1994-01-03  |  8KB  |  390 lines

  1. # include "BuildTre.h"
  2. # include "yyBTree.w"
  3. # include <stdio.h>
  4. # if defined __STDC__ | defined __cplusplus
  5. #  include <stdlib.h>
  6. # else
  7.    extern void exit ();
  8. # endif
  9. # include "Tree.h"
  10.  
  11. # ifndef NULL
  12. # define NULL 0L
  13. # endif
  14. # ifndef false
  15. # define false 0
  16. # endif
  17. # ifndef true
  18. # define true 1
  19. # endif
  20.  
  21. # ifdef yyInline
  22. # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) \
  23.   if ((ptr = (tree) free) >= (tree) max) ptr = alloc (); \
  24.   free += nodesize [kind]; \
  25.   ptr->yyHead.yyMark = 0; \
  26.   ptr->Kind = kind;
  27. # else
  28. # define yyALLOC(tree, free, max, alloc, nodesize, make, ptr, kind) ptr = make (kind);
  29. # endif
  30.  
  31. # define yyWrite(s) (void) fputs (s, yyf)
  32. # define yyWriteNl (void) fputc ('\n', yyf)
  33.  
  34. # line 26 "BuildTree.puma"
  35.  
  36.  
  37.  
  38. static FILE * yyf = stdout;
  39.  
  40. static void yyAbort
  41. # ifdef __cplusplus
  42.  (char * yyFunction)
  43. # else
  44.  (yyFunction) char * yyFunction;
  45. # endif
  46. {
  47.  (void) fprintf (stderr, "Error: module BuildTree, routine %s failed\n", yyFunction);
  48.  exit (1);
  49. }
  50.  
  51. tTree ConcatDecls ARGS((tTree list1, tTree list2));
  52. tTree CompleteDecls ARGS((tTree list));
  53. void SetImplicitType ARGS((tTree declist, tTree type));
  54. void SetIntent ARGS((tTree declist, int intent));
  55. static void SetNewAttributes ARGS((tTree attlist, tTree entity, bool is_last));
  56. void SetAttributes ARGS((tTree attlist, tTree entlist));
  57. tTree IndependentForall ARGS((tTree loop));
  58.  
  59. tTree ConcatDecls
  60. # if defined __STDC__ | defined __cplusplus
  61. (register tTree list1, register tTree list2)
  62. # else
  63. (list1, list2)
  64.  register tTree list1;
  65.  register tTree list2;
  66. # endif
  67. {
  68. # line 40 "BuildTree.puma"
  69.   {
  70. # line 41 "BuildTree.puma"
  71.    if (! ((list1 == NoTree))) goto yyL1;
  72.   }
  73.    return list2;
  74. yyL1:;
  75.  
  76.   if (list1->Kind == kDECL_EMPTY) {
  77. # line 45 "BuildTree.puma"
  78.    return list2;
  79.  
  80.   }
  81.   if (list1->Kind == kDECL_LIST) {
  82. # line 49 "BuildTree.puma"
  83.   {
  84. # line 50 "BuildTree.puma"
  85.  list1->DECL_LIST.Next = ConcatDecls (list1->DECL_LIST.Next, list2);
  86.   }
  87.    return list1;
  88.  
  89.   }
  90.  yyAbort ("ConcatDecls");
  91. }
  92.  
  93. tTree CompleteDecls
  94. # if defined __STDC__ | defined __cplusplus
  95. (register tTree list)
  96. # else
  97. (list)
  98.  register tTree list;
  99. # endif
  100. {
  101. # line 56 "BuildTree.puma"
  102.   {
  103. # line 57 "BuildTree.puma"
  104.    if (! ((list == NoTree))) goto yyL1;
  105.   }
  106.    return mDECL_EMPTY ();
  107. yyL1:;
  108.  
  109.   if (list->Kind == kDECL_EMPTY) {
  110. # line 61 "BuildTree.puma"
  111.    return list;
  112.  
  113.   }
  114.   if (list->Kind == kDECL_LIST) {
  115. # line 65 "BuildTree.puma"
  116.   {
  117. # line 66 "BuildTree.puma"
  118.  list->DECL_LIST.Next = CompleteDecls (list->DECL_LIST.Next);
  119.   }
  120.    return list;
  121.  
  122.   }
  123.  yyAbort ("CompleteDecls");
  124. }
  125.  
  126. void SetImplicitType
  127. # if defined __STDC__ | defined __cplusplus
  128. (register tTree declist, register tTree type)
  129. # else
  130. (declist, type)
  131.  register tTree declist;
  132.  register tTree type;
  133. # endif
  134. {
  135.   if (declist == NoTree) return;
  136.   if (type == NoTree) return;
  137. # line 78 "BuildTree.puma"
  138.   {
  139. # line 79 "BuildTree.puma"
  140.    if (! ((declist == NoTree))) goto yyL1;
  141.   }
  142.    return;
  143. yyL1:;
  144.  
  145.   if (declist->Kind == kDECL_LIST) {
  146.   if (declist->DECL_LIST.Elem->Kind == kIMPLICIT_DECL) {
  147. # line 82 "BuildTree.puma"
  148.   {
  149. # line 83 "BuildTree.puma"
  150.  declist->DECL_LIST.Elem->IMPLICIT_DECL.VAL = type;
  151. # line 84 "BuildTree.puma"
  152.    SetImplicitType (declist->DECL_LIST.Next, type);
  153.   }
  154.    return;
  155.  
  156.   }
  157. # line 87 "BuildTree.puma"
  158.   {
  159. # line 88 "BuildTree.puma"
  160.    SetImplicitType (declist->DECL_LIST.Next, type);
  161.   }
  162.    return;
  163.  
  164.   }
  165. # line 91 "BuildTree.puma"
  166.   {
  167. # line 92 "BuildTree.puma"
  168.    printf ("illegal call of SetImplicitType\n");
  169. # line 93 "BuildTree.puma"
  170.    WriteTree (stdout, declist);
  171.   }
  172.    return;
  173.  
  174. ;
  175. }
  176.  
  177. void SetIntent
  178. # if defined __STDC__ | defined __cplusplus
  179. (register tTree declist, register int intent)
  180. # else
  181. (declist, intent)
  182.  register tTree declist;
  183.  register int intent;
  184. # endif
  185. {
  186.   if (declist == NoTree) return;
  187. # line 104 "BuildTree.puma"
  188.   {
  189. # line 105 "BuildTree.puma"
  190.    if (! ((declist == NoTree))) goto yyL1;
  191.   }
  192.    return;
  193. yyL1:;
  194.  
  195.   if (declist->Kind == kDECL_LIST) {
  196.   if (declist->DECL_LIST.Elem->Kind == kINTENT_DECL) {
  197. # line 108 "BuildTree.puma"
  198.   {
  199. # line 109 "BuildTree.puma"
  200.  declist->DECL_LIST.Elem->INTENT_DECL.intent = intent;
  201. # line 110 "BuildTree.puma"
  202.    SetIntent (declist->DECL_LIST.Next, intent);
  203.   }
  204.    return;
  205.  
  206.   }
  207.   }
  208. # line 113 "BuildTree.puma"
  209.   {
  210. # line 114 "BuildTree.puma"
  211.    printf ("illegal call of SetIntent\n");
  212. # line 115 "BuildTree.puma"
  213.    WriteTree (stdout, declist);
  214.   }
  215.    return;
  216.  
  217. ;
  218. }
  219.  
  220. static void SetNewAttributes
  221. # if defined __STDC__ | defined __cplusplus
  222. (register tTree attlist, register tTree entity, register bool is_last)
  223. # else
  224. (attlist, entity, is_last)
  225.  register tTree attlist;
  226.  register tTree entity;
  227.  register bool is_last;
  228. # endif
  229. {
  230.   if (attlist == NoTree) return;
  231.   if (entity == NoTree) return;
  232. # line 132 "BuildTree.puma"
  233.   {
  234. # line 133 "BuildTree.puma"
  235.    if (! ((attlist == NoTree))) goto yyL1;
  236.   }
  237.    return;
  238. yyL1:;
  239.  
  240.   if (attlist->Kind == kDECL_LIST) {
  241.   if (entity->Kind == kENTITY_DECL) {
  242. # line 136 "BuildTree.puma"
  243.   {
  244. # line 137 "BuildTree.puma"
  245.    if (! ((is_last == true))) goto yyL2;
  246.   {
  247. # line 138 "BuildTree.puma"
  248.    SetNewAttributes (attlist->DECL_LIST.Next, entity, is_last);
  249. # line 139 "BuildTree.puma"
  250.  attlist->DECL_LIST.Next       = entity->ENTITY_DECL.ATTRIBUTES;
  251.     entity->ENTITY_DECL.ATTRIBUTES = attlist;
  252.  
  253.   }
  254.   }
  255.    return;
  256. yyL2:;
  257.  
  258. # line 144 "BuildTree.puma"
  259.   {
  260. # line 145 "BuildTree.puma"
  261.    if (! ((is_last != true))) goto yyL3;
  262.   {
  263. # line 146 "BuildTree.puma"
  264.    SetNewAttributes (attlist->DECL_LIST.Next, entity, is_last);
  265. # line 147 "BuildTree.puma"
  266.  entity->ENTITY_DECL.ATTRIBUTES = mDECL_LIST (CopyTree (attlist->DECL_LIST.Elem), entity->ENTITY_DECL.ATTRIBUTES);
  267.   }
  268.   }
  269.    return;
  270. yyL3:;
  271.  
  272.   }
  273.   }
  274. # line 150 "BuildTree.puma"
  275.   {
  276. # line 151 "BuildTree.puma"
  277.    printf ("illegal call of SetNewAttributes\n");
  278. # line 152 "BuildTree.puma"
  279.    WriteTree (stdout, attlist);
  280.   }
  281.    return;
  282.  
  283. ;
  284. }
  285.  
  286. void SetAttributes
  287. # if defined __STDC__ | defined __cplusplus
  288. (register tTree attlist, register tTree entlist)
  289. # else
  290. (attlist, entlist)
  291.  register tTree attlist;
  292.  register tTree entlist;
  293. # endif
  294. {
  295.   if (attlist == NoTree) return;
  296.   if (entlist == NoTree) return;
  297. # line 170 "BuildTree.puma"
  298.   {
  299. # line 171 "BuildTree.puma"
  300.    if (! ((entlist == NoTree))) goto yyL1;
  301.   }
  302.    return;
  303. yyL1:;
  304.  
  305.   if (entlist->Kind == kDECL_LIST) {
  306.   if (entlist->DECL_LIST.Elem->Kind == kENTITY_DECL) {
  307. # line 175 "BuildTree.puma"
  308.  {
  309.   bool is_last;
  310.   {
  311. # line 177 "BuildTree.puma"
  312.  
  313. # line 179 "BuildTree.puma"
  314.  is_last = (entlist->DECL_LIST.Next == NoTree);
  315.     SetNewAttributes (attlist, entlist->DECL_LIST.Elem, is_last);
  316.  
  317. # line 182 "BuildTree.puma"
  318.    SetAttributes (attlist, entlist->DECL_LIST.Next);
  319.   }
  320.    return;
  321.  }
  322.  
  323.   }
  324.   }
  325. # line 185 "BuildTree.puma"
  326.   {
  327. # line 186 "BuildTree.puma"
  328.    printf ("illegal call of SetAttributes\n");
  329. # line 187 "BuildTree.puma"
  330.    WriteTree (stdout, entlist);
  331.   }
  332.    return;
  333.  
  334. ;
  335. }
  336.  
  337. tTree IndependentForall
  338. # if defined __STDC__ | defined __cplusplus
  339. (register tTree loop)
  340. # else
  341. (loop)
  342.  register tTree loop;
  343. # endif
  344. {
  345.   if (loop->Kind == kACF_FORALL) {
  346. # line 201 "BuildTree.puma"
  347.  {
  348.   tTree newloop;
  349.   {
  350. # line 202 "BuildTree.puma"
  351.  
  352. # line 203 "BuildTree.puma"
  353.  loop->ACF_FORALL.FORALL_BODY = IndependentForall (loop->ACF_FORALL.FORALL_BODY);
  354.       newloop = mACF_DOALL (mBTV_EMPTY (), loop->ACF_FORALL.FORALL_ID, loop->ACF_FORALL.FORALL_RANGE, loop->ACF_FORALL.FORALL_BODY);
  355.       newloop->ACF_DOALL.Label = loop->ACF_FORALL.Label;
  356.       newloop->ACF_DOALL.Line  = loop->ACF_FORALL.Line;
  357.  
  358.   }
  359.   {
  360.    return newloop;
  361.   }
  362.  }
  363.  
  364.   }
  365.   if (loop->Kind == kACF_LIST) {
  366.   if (loop->ACF_LIST.Elem->Kind == kACF_FORALL) {
  367.   if (loop->ACF_LIST.Next->Kind == kACF_EMPTY) {
  368. # line 211 "BuildTree.puma"
  369.   {
  370. # line 212 "BuildTree.puma"
  371.  loop->ACF_LIST.Elem = IndependentForall (loop->ACF_LIST.Elem);
  372.   }
  373.    return loop;
  374.  
  375.   }
  376.   }
  377.   }
  378. # line 216 "BuildTree.puma"
  379.    return loop;
  380.  
  381. }
  382.  
  383. void BeginBuildTree ()
  384. {
  385. }
  386.  
  387. void CloseBuildTree ()
  388. {
  389. }
  390.